<!--
 * @Author: yaoling 1871883713@qq.com
 * @Date: 2022-10-20 09:06:50
 * @LastEditors: yaoling 1871883713@qq.com
 * @LastEditTime: 2022-12-21 11:25:19
 * @FilePath: \company-world\src\views\homepage\components\News.vue
 * @Description: 公告详情
-->
<template>
  <section class="details">
    <el-dialog
      v-model="dialogVisible"
      :show-close="false"
      width="50%"
      top="10vh"
      :before-close="handleClose"
      draggable
    >
      <div
        class="data-content"
        :style="
          !show
            ? 'max-height: 700px;overflow-y: auto;padding-right: 8px;margin: 0 auto;'
            : 'max-height: 100%;width: 640px;height: 100%;'
        "
      >
        <div class="detail-title">{{ activeList.data_title }}</div>
        <div class="time-and-name">
          <span>{{ activeList.created_at }}</span>
          <span>来源：{{ activeList.writer }}</span>
        </div>
        <div class="text">
          <v-md-editor mode="preview" width="100%" v-model="activeList.data_content"></v-md-editor>
        </div>
      </div>
      <footer class="footer">
        <el-button @click="handleClose" class="btn button">关闭</el-button>
        <el-button class="btn" color="#6C52EA" @click="handleSave">确认收到</el-button>
      </footer>
    </el-dialog>
  </section>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue'
const props = defineProps({
  // dialogVisible显示隐藏
  dialog: {
    type: Boolean,
    required: true,
    default: false
  },
  // 点击数据
  activeList: {
    type: Object,
    required: true,
    default: () => {
      ;[]
    }
  }
})
const dialogVisible = ref(false)
watch(
  () => props.dialog,
  (newVal) => {
    dialogVisible.value = newVal
  }
)
/**
 * @desc:确认收到
 */
const handleSave = () => {
  emits('handleSave')
}
/**
 * @desc:放大预览
 */
const show = ref(false)
const openFullscreen = () => {
  show.value = !show.value
}
/**
 * @desc:关闭弹窗
 */
const emits = defineEmits(['handle-close-click', 'handleSave'])
const handleClose = () => {
  dialogVisible.value = false
  emits('handle-close-click')
}
</script>

<style lang="less" scoped>
:deep(.el-dialog) {
  border-radius: 10px;
}
.details {
  position: relative;
  .my-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    overflow-x: hidden;
    overflow-y: auto;
    height: 420px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(220, 223, 230, 1);
    cursor: pointer;
    h6 {
      font-size: 16px;
    }
    .dialog-right {
      display: flex;
      justify-content: space-between;
      width: 4%;
      font-size: 14px;
      .icon {
        margin-top: 4px;
      }
    }
  }
  .data-content {
    overflow-x: hidden;
    overflow-y: auto;
    height: 280px;
    padding: 0 5%;
    padding-bottom: 10px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(220, 223, 230, 1);
    .detail-title {
      width: 100%;
      height: 32px;
      line-height: 32px;
      text-align: left;
      font-size: 16px;
      font-weight: 550;
    }
    .time-and-name {
      width: 100%;
      height: 20px;
      line-height: 20px;
      display: flex;
      justify-content: flex-start;
      margin: 10px 0 30px 0;
      span {
        height: 20px;
        font-size: 13px;
        color: #999;
        margin-right: 10px;
      }
    }
    .text {
      line-height: normal;
      p {
        line-height: 2;
      }
    }
  }
  .footer {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
    padding-top: 10px;
    text-align: right;
    .btn {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 150px;
      height: 48px;
      padding: 15px 61px 15px 61px;
      border: 1px solid rgba(220, 223, 230, 1);
      opacity: 1;
      border-radius: 4px;
    }
  }
}
</style>
